/**
 * Created by qunxing.du on 2016/8/2.
 * Copyright 2016 汉威.智慧环保事业部 Limited.
 * All rights reserved.
 */
package com.hw.one.collect.zzcity.handler;

import com.hw.one.collect.data.DataService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * 数据有效性过滤处理器
 */
@Component
public class ValidDataHandler extends DataService implements IHandler {
    private static Logger log = Logger.getLogger(ValidDataHandler.class);
    private static final String PADDING_VAL = null;//填充值
    /**
     * 有效数据过滤处理方法
     * @param o            数据
     * @param name         数据集合
     * @param handlerChain
     * @return
     * @throws Exception
     */
    @Override
    public synchronized Object handle(Object o, String name, HandlerChain handlerChain) throws Exception {
        List<Map> list = (List<Map>) o;
        for (Map<String,Object> map :  list) {
            String mark = (String) map.get("Mark");
            if(mark != null && !mark.isEmpty()){
                map.put("Monvalue",PADDING_VAL);
            }
        }
        log.debug("有效数据条数：" + list.size());
        return handlerChain.handle(list,name,handlerChain);
    }
}
